package com.jcl.recruit.elasticsearch.mapper;

import com.jcl.recruit.elasticsearch.resume.vo.ElasticReportCondition;
import com.jcl.recruit.mapper.SqlMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @ClassName ConsoleReportSearchResumeMapper
 * @Author yyliu
 * @Date 2018/12/25 14:34
 * @Version 1.0
 **/
public interface ConsoleReportSearchResumeMapper extends SqlMapper {

    @Select({
            QUERY_SCRIPT_START,
            "SELECT source_sub AS source, COUNT(*) number FROM search_resume_basic_info ",
            QUERY_WHERE_START,
            IF_START_CORP_CODE,
            SQL_CORP_CODE,
            IF_END,
            "<if test='null!=startDate'>",
            " and create_time &gt;= #{startDate}",
            IF_END,
            "<if test='null!=endDate'>",
            " and create_time &lt; #{endDate}",
            IF_END,
            QUERY_WHERE_END,
            " GROUP BY source_sub ",
            QUERY_SCRIPT_END
    })
    List<Map<String, Object>> pieChar(ElasticReportCondition condition);

    @Select({
            QUERY_SCRIPT_START,
            "SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS days, source_sub AS source, COUNT(source_sub) number FROM search_resume_basic_info ",
            QUERY_WHERE_START,
            IF_START_CORP_CODE,
            SQL_CORP_CODE,
            IF_END,
            "<if test='null!=startDate'>",
            " and create_time &gt;= #{startDate}",
            IF_END,
            "<if test='null!=endDate'>",
            " and create_time &lt; #{endDate}",
            IF_END,
            QUERY_WHERE_END,
            " GROUP BY days, source_sub ",
            " ORDER BY create_time asc ",
            QUERY_SCRIPT_END
    })
    List<Map<String, Object>> barGraph(ElasticReportCondition condition);
}
